<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>用户登录</h1>
<form action="">
    <input type="text" name="username" v-model="user.username" placeholder="用户名"><br>
    <input type="password" name="password" v-model="user.password" placeholder="密码"><br>
    <input type="checkbox" name="rem" v-model="user.rem">记住用户名和密码<br>
    <input type="button" value="登录" @click="login()">
</form>
<script src="js/axios.min.js"></script>
<script src="js/vue.min.js"></script>
<script>
    let  v = new Vue({
        el:"form",
        data:{
            user:{
                username:"",
                password:""
            }
        },
        methods:{
            login(){
                axios.post("/login",v.user).then(function(response){
                    if(response.data==1){
                        alert("登录成功");
                        location.href="/";//跳转到首页
                    }else if(response.data==2){
                        alert("用户不存在");
                    }else{
                        alert("密码错误")
                    }

                })
            }
        }
    })
</script>
</body>
</html>